package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author by 孙有泽
 * @Date 2024/11/28 22:01
 * @Description 护理项目接口
 */
@RestController
@RequestMapping("/nursing_project")
public class NursingProjectController extends BaseController{

    @Autowired
    private NursingProjectService nursingProjectService;
    /*
     * @author 孙有泽
     * @date 2024/12/2 12:44
     * @description 护理项目分页查询
     */
    @GetMapping("/page")
    public ResponseResult getByPage(@RequestParam(value = "name",required = false)String name,
                                      @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                      @RequestParam(value = "status",required = false) Integer status) {
        PageResponse<NursingProjectVo> byPage = nursingProjectService.getByPage(name, pageNum, pageSize, status);
        return ResponseResult.success(byPage);
    }
    /*
    * @author 孙有泽
    * @date 2024/12/4 21:34
    * @description 护理项目新增
    */
    @PostMapping("/add")
    public ResponseResult add(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.add(nursingProjectDto);
        return success();
    }
    /*
     * @author 孙有泽
     * @date 2024/12/5 21:01
     * @description 根据id查询护理项目
     */
    @GetMapping("/{id}")
    public ResponseResult getById(@PathVariable("id") Long id){
        NursingProjectVo nursingProjectVo= nursingProjectService.getById(id);
        return success(nursingProjectVo);
    }
    /*
     * @author 孙有泽
     * @date 2024/12/5 21:20
     * @description 护理项目的更新
     */
    @PutMapping("/update")
    public ResponseResult update(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.update(nursingProjectDto);
        return success();
    }


}
